package com.itheima.stock.job.jobhandler;

import com.itheima.stock.job.service.StockTimerService;
import com.xxl.job.core.handler.annotation.XxlJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.ParseException;

/**
 * 定义股票相关数据的定时任务
 * @author laofang
 */
@Component
public class StockJob {
    // 记录日志
    private static Logger logger = LoggerFactory.getLogger(StockJob.class);

    @Autowired
    private StockTimerService stockTimerService;

    /**
     * 定时拉取个股数据
     */
    @XxlJob("getStockRtIndex")
    public void jobStockRtIndex() throws ParseException {
        stockTimerService.insertBatchRt();
    }

    /**
     * 创建定时任务
     */
    @XxlJob("hema_job_test")
    public void jobTest(){
        System.out.println("jobTest run.....");
    }
    // 初始化方法
    public void init(){
        logger.info("init");
    }

    // 销毁方法
    public void destroy(){
        logger.info("destory");
    }
}